package main.java.tmi.popup.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import main.java.tmi.common.service.impl.AbstractDao;
import main.java.tmi.customer.service.CustomerVO;
import main.java.tmi.order.service.OrderVO;
import main.java.tmi.returnProduct.service.ReturnProductVO;
import main.java.tmi.stockOut.service.StockOutVO;
import main.java.tmi.packing.service.PackingVO;
import main.java.tmi.popup.service.PopupVO;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

/**
 * Customer Data Access Object (cust Table)
 *
 * @author min™
 * @since 2012. 04. 24
 */
@Repository
public class PopupDAO extends AbstractDao {
	
	/**
	 * Customer search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<CustomerVO> getCustomerPopView(Map<String,String> param) throws SQLException {
				
		return (List<CustomerVO>) list("PopupDAO.getCustomerPopView", param);
	}
	
	/**
	 * Customer search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getCustomerPopCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getCustomerPopCount", param));
	}
	
	/**
	 * Product search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<CustomerVO> getProductPopView(Map<String,String> param) throws SQLException {
				
		return (List<CustomerVO>) list("PopupDAO.getProductPopView", param);
	}
	
	/**
	 * Product search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getProductPopCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getProductPopCount", param));
	}
	

	
	   /**
	  * orderNum count search
	  * @return String
	  * @throws SQLException 
	  */
	 @SuppressWarnings("unchecked")
	 public int getOrderNumListCount(Map<String,String> param) throws SQLException {
	     return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getOrderNumListCount", param));
	 }
	 
	 /**
	  * Product search
	  * @return List<OrderVO>
	  * @throws SQLException 
	  */
	 @SuppressWarnings("unchecked")
	 public List<OrderVO> getOrderNumList(Map<String,String> param) throws SQLException {
	             
	     return (List<OrderVO>) list("PopupDAO.getOrderNumList", param);
	 }
	 
	 
	 
	   /**
	  * orderNum count search
	  * @return String
	  * @throws SQLException 
	  */
	 @SuppressWarnings("unchecked")
	 public int getPackingNumListCount(Map<String,String> param) throws SQLException {
		 System.out.println("=================="+param);
	     return Integer.parseInt(StringUtils.defaultString( (String) getSqlMapClientTemplate().queryForObject("PopupDAO.getPackingNumListCount", param) , "0"));
	 }
	 
	 /**
	  * Product search
	  * @return List<OrderVO>
	  * @throws SQLException 
	  */
	 @SuppressWarnings("unchecked")
	 public List<PackingVO> getPackingNumList(Map<String,String> param) throws SQLException {
	             
	     return (List<PackingVO>) list("PopupDAO.getPackingNumList", param);
	 }
	 
	 
	 
	   /**
	  * MawbHawbNum count search
	  * @return String
	  * @throws SQLException 
	  */
	 @SuppressWarnings("unchecked")
	 public int getMawbHawbNumListCount(Map<String,String> param) throws SQLException {
		 System.out.println("=================="+param);
		 int resultCnt ;
		 if(param.get("menuType").toString().equals("CLEARANCE")){
			 resultCnt = Integer.parseInt(StringUtils.defaultString( (String) getSqlMapClientTemplate().queryForObject("PopupDAO.getMawbHawbNumListCount2", param) , "0"));
		 }else if(param.get("menuType").toString().equals("AIR")){
			 resultCnt = Integer.parseInt(StringUtils.defaultString( (String) getSqlMapClientTemplate().queryForObject("PopupDAO.getMawbHawbNumListCount3", param) , "0"));
		 }else{
			 resultCnt = Integer.parseInt(StringUtils.defaultString( (String) getSqlMapClientTemplate().queryForObject("PopupDAO.getMawbHawbNumListCount", param) , "0"));
		 }
	     return resultCnt;
	 }
	 
	 /**
	  * MawbHawbNum search
	  * @return List<PopupVO>
	  * @throws SQLException 
	  */
	 @SuppressWarnings("unchecked")
	 public List<PopupVO> getMawbHawbNumList(Map<String,String> param) throws SQLException {
		 List resultList;
		 if(param.get("menuType").toString().equals("CLEARANCE")){
			 resultList = (List<PopupVO>) list("PopupDAO.getMawbHawbNumList2", param);
		 }else if(param.get("menuType").toString().equals("AIR")){
			 resultList = (List<PopupVO>) list("PopupDAO.getMawbHawbNumList3", param);
		 }else{
			 resultList = (List<PopupVO>) list("PopupDAO.getMawbHawbNumList", param);
		 }
	     return resultList;
	 }

	/**
	 * StockOut PopUp search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<StockOutVO> getStockOutPopView(Map<String,String> param) throws SQLException {
				
		return (List<StockOutVO>) list("PopupDAO.getStockOutPopView", param);
	}
	
	/**
	 * StockOut PopUp search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getStockOutPopCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getStockOutPopCount", param));
	}

	/**
	 * StockOut No PopUp search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<StockOutVO> getStockOutNoPopView(Map<String,String> param) throws SQLException {
				
		return (List<StockOutVO>) list("PopupDAO.getStockOutNoPopView", param);
	}
	
	/**
	 * StockOut No PopUp search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getStockOutNoPopCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getStockOutNoPopCount", param));
	}

	/**
	 * ReturnProduc PopUp search
	 * @return List<ReturnProductVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<ReturnProductVO> getReturnProducPopView(Map<String,String> param) throws SQLException {
				
		return (List<ReturnProductVO>) list("PopupDAO.getReturnProducPopView", param);
	}
	
	/**
	 * ReturnProduc PopUp search
	 * @return int
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getReturnProducPopCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getReturnProducPopCount", param));
	}
	
	/**
	 * Return NO PopUp search
	 * @return List<ReturnProductVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<ReturnProductVO> getReturnNoPopView(Map<String,String> param) throws SQLException {
				
		return (List<ReturnProductVO>) list("PopupDAO.getReturnNoPopView", param);
	}
	
	/**
	 * Return NO count search
	 * @return int
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getReturnNoPopCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("PopupDAO.getReturnNoPopCount", param));
	}
}
